<?php
uses('model');

class globalModel extends Model {

    function __construct() {
        parent::__construct();
    }

    //博客最新文章
    function indexBlog($v) {
        $this->dbconnect();


        if ($v['update']) {
            $this->db->cacheflush = true;
            //$data = $this->db->CacheGetAll('blog_posts', 'ID,post_title,post_excerpt,guid,post_date', "post_excerpt<>'' AND post_status='publish' ORDER BY ".$v['sort']." {$v['sortorder']}"." LIMIT {$v['limit']}");
            $data = $this->db->CacheGetAll('blog_posts', 'ID,post_title,post_excerpt,guid,post_date', "post_status='publish' ORDER BY ".$v['sort']." {$v['sortorder']}"." LIMIT {$v['limit']}");
            $this->db->cacheflush = false;
        }
        $data = $this->db->CacheGetAll('blog_posts', 'ID,post_title,post_excerpt,guid,post_date', "post_status='publish' ORDER BY ".$v['sort']." {$v['sortorder']}"." LIMIT {$v['limit']}");

        return $data;
    }

    //厂商联系
    function contactMail($v) {
        $this->dbconnect();

        $f['subject']   =   "产品合作邮件 - ". $v['name'];
        $f['mailto']    =   $this->cfg['admin_mail'];
        $f['body']      =   "姓名:{$v['name']}\r\n";
        $f['body']      .=  "公司名:{$v['company']}\r\n";
        $f['body']      .=  "电话:{$v['tel']}\r\n";
        $f['body']      .=  "Email:{$v['email']}\r\n";
        $f['body']      .=  "IM:{$v['im']}\r\n";
        $f['body']      .=  "公司说明:{$v['desc']}\r\n";
        $f['body']      .=  "产品说明:{$v['product']}";
        $f['created']   =   time();

        $this->db->Insert($this->table['mail'], $f);

        return true;
    }
}
?>
